import React, { Component } from 'react';
import {
    StyleSheet,
    Text,
    View,
    Image,
    Dimensions,
    TouchableOpacity
} from 'react-native'
import Swiper from 'react-native-swiper';
import Style from '../utils/style/style'
import Constant from '../utils/Constant';
export default class SwiperView extends Component {
    constructor(props) {
        super(props)
    }

    render() {
        const HOST = Constant.HOST;
        const { bannerList } = this.props;
        // defaultSource={require('../static/banner.jpg')}
        return (
            <View style={styles.container}>
                <Swiper style={styles.wrapper} autoplay={true} showsPagination={false} >
                    {
                        bannerList.map((item, index) =>
                            (
                                <TouchableOpacity style={styles.banner} key={index} onPress={() => this.props.pressItem(item)} activeOpacity={1}>
                                    <Image
                                        style={styles.bannerImg}
                                        resizeMode='cover'
                                        source={{ uri: HOST + item.topicAttach }}
                                    />
                                </TouchableOpacity>
                            )
                        )
                    }
                </Swiper>
            </View>
        )
    }

}
let { height, width } = Dimensions.get('window');
const styles = StyleSheet.create({
    container: {
        height: Style.bannerHeight,
    },
    wrapper: {
    },
    banner: {
        height: Style.bannerHeight,
        width: Style.width,
    },
    bannerImg: {
        height: Style.bannerHeight,
        width: Style.width,
    }
})
